﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DesignPattern.StrategyPattern
{
    public partial class FormStrategy : Form
    {
        public FormStrategy()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Context context=new Context(comboBox1.Text);
            //Strategy stg = context.CreateStrategy(comboBox1.Text);
            string str="单价："+double.Parse(textBox1.Text)+" 数量："+double.Parse(textBox2.Text)+" 优惠："+comboBox1.Text+" 应收：";
            //listBox1.Items.Add(str + stg.AcceptCash(double.Parse(textBox1.Text)*double.Parse(textBox2.Text)));
            listBox1.Items.Add(str + context.GetResult(double.Parse(textBox1.Text) * double.Parse(textBox2.Text)));
        }

        private void button2_Click(object sender, EventArgs e)
        {
            listBox1.Items.Remove(listBox1.SelectedItem);
        }
    }
}
